#!/bin/bash
# desc start - wget https://hello.fe80.cn/bash/openresty.sh && bash openresty.sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
cur_dir=$(pwd)

Color_Text()
{
  echo -e " \e[0;$2m$1\e[0m"
}

Echo_Red()
{
  echo $(Color_Text "$1" "31")
}

Echo_Green()
{
  echo $(Color_Text "$1" "32")
}

Echo_Yellow()
{
  echo $(Color_Text "$1" "33")
}

Echo_Blue()
{
  echo $(Color_Text "$1" "34")
}

# Check if user is root
if [ $(id -u) != "0" ]; then
    Echo_Red "Error: You must be root to run this script, please use root to install"
    exit 1
fi

cd ~

yum install yum-utils -y

yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

yum install openresty -y

yum install openresty-resty -y
